<%@ include file="../common2.jspf" %>
<script type="text/javascript">
	/*	
	function clickSearch(parentNO) {
		$('#buttonCreate').click(function() {
			location.href = 'create?parentNO=' + parentNO;
		});
		$.post('list?parentNO=' + parentNO, {}, searchClicked, 'json');
	}
	
	function searchClicked(data) {
		var keys = ['categoryNO', 'name', 'parentNO', 'date'];
		$('table.result tbody').html('');
		
		for (var i = 0; i < data.length; i++) {
			var item = data[i];
		
			$tr = $('<tr>');
			$.each(keys, function() {
				var $td = $('<td>').text(item[this]);
				$tr.append($td);
			});
			
			var eventData = {categoryNO: item.categoryNO, parentNO: item.parentNO};
			var $listBtn = $('<button>').attr('type', 'button').text('List').click(eventData, list);
			var $readBtn = $('<button>').attr('type', 'button').text('Read').click(eventData, read);
			$tr.append($('<td>').append($readBtn, $listBtn));
			
			$('table.result tbody').append($tr);
		}
	}
	
	function read(event) {
		location.href = 'read?categoryNO=' + event.data.categoryNO + '&parentNO=' + event.data.parentNO; 
	}
	
	function list(event) {
		location.href = 'list?parentNO=' + event.data.parentNO;
	}
	*/
</script>

<table class="result">
	<tbody>
		<c:forEach var="category" items="${categoryList}">
			<tr>
				<td>${category.categoryNO}</td>
				<td>${category.name}</td>
				<td>${category.parentNO}</td>
				<td><fmt:formatDate value="${category.date}" pattern="yyyy/MM/dd"/></td>
				<td>
					<button type="button" onclick="location.href = 'read?categoryNO=${category.categoryNO}';">Read</button>
					<button type="button" onclick="location.href = 'list?parentNO=${category.categoryNO}';">List</button>
				</td>
			</tr>
		</c:forEach>
	</tbody>
</table>

<!-- Button -------------------->
<footer>
	<button id="buttonCreate" type="button" onclick="location.href = 'create?parentNO=${category.parentNO}'"><fmt:message key="create"/></button>
</footer>
<!-------------------- Button -->